package interfaces;

import java.io.IOException;
import java.net.UnknownHostException;
import java.util.Vector;
import domain.items.Item;
import domain.items.PostPacket;
import domain.items.TopicPacket;
import domain.users.User;

public interface UserConnection {

	/**
	 * when the surfer chooses to login (in any given moment\page)
	 */
	public boolean login(String userName, String password);

	/**
	 * when the surfer wants to add himself to the user repository.
	 */
	public boolean registerUser(String username, String Email,String password);

	/**
	 * when user wants to logout and come back to the welcome page
	 */
	public boolean logout();

	/**
	 * in case some info of the connected user is needed
	 */
	public User getUser();

	/**
	 * get the starting point for navigating in the forum
	 */
	public TopicPacket getRootTopic();

	/**
	 * in case permission checking is needed.
	 */
	public int getUserRank();

	/**
	 * in any given moment the surfer is viewing ONE ITEM and sees a list of
	 * ALL RELEVANT SUB-ITEMS. this method allows him to navigate into one of
	 * the listed sub-item by its number.
	 */
	public Item getItem(int choice);

    /**
     * adding a Post to the forum
     * @param subject
     * @param text
     */
	public boolean addPost(String subject, String text);

	/**
	 * modifying a Post
	 * @return
	 */
	public boolean updatePost(String newSubject,String newText);

	/**
	 * deleting a post
	 * @return
	 */
	public boolean deletePost();

	/**
	 * adding a new Thread to the Forum
	 * DO NOT FORGET!! - BY CREATING A NEW MESSAGE YOU ALREADY HAVE THE THREAD'S SUBJECT (HIS FIRST MESSAGE'S SUBJECT)
	 * THUS, IMPLEMENTATION SHOULD ALWAYS INCLUDE THE CREATION OF A NEW MESSAGE.
	 */
	public boolean addThread(String newMessageSubject, String newMessageText);

	/**
	 * get the current item
	 */
	public Item getCurrentlyViewedItem();

	/**
	 * set the current item
	 * @param item
	 * @return
	 */
	public boolean setCurrentlyViewedItem(Item item);

	/**
	 * decrement user rank by 1
	 * @param username
	 * @return
	 */
	public boolean demoteUser(String username);

	/**
	 * increment user rank by 1
	 * @param username
	 * @return
	 */
	public boolean PromoteUser(String username);

	/**
	 * establish a connection to the server
	 * (this includes any handshake that should be defined between
	 * the UserConnection and the WsepHandler)
	 * @param hostname
	 * @param port
	 * @throws UnknownHostException
	 * @throws IOException
	 */
	public void connect(String hostname, int port) throws UnknownHostException, IOException;

	/**
	 * get the current item's father
	 * @return
	 */
	public Item getFather();

	/**
	 *
	 * @param authorName
	 * @return vector of posts
	 */
	public Vector<PostPacket> searchByAuthor(String authorName);

	/**
	 *
	 * @param from
	 * @param to
	 * @return vector of posts
	 */
	public Vector<PostPacket> searchByDate(String fromDate, String toDate);

	/**
	 *
	 * @param sentence
	 * @return vector of posts
	 */
	public Vector<PostPacket> searchByContent(String sentence);

	/**
	 *
	 * @param username
	 * @return
	 */
	public boolean deleteUser(String username);

	public String getStatus();

	public boolean updateUser(String newEmail,String oldPass, String newPass1);

}
